<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>The Ajax 03 Page</h1>
    <button onclick="doAjaxGet()">Do Ajax Get</button>
    <button onclick="doAjaxPost()">Do Ajax Post</button>
    <button onclick="doAjaxPostJson()">Do Ajax Post Json</button>
    <button onclick="doAjaxDelete()">Do Ajax Delete</button>
    <button onclick="doAjaxPut()">Do Ajax Put</button>
</div>
<div id="result"></div>
<script src="/js/ajax.js"></script>
<script>
    //ajax post request
    function doAjaxPostJson(){
        const url="/doAjaxPostJSON";
        const params={id:"103",city:"xiongan"};//服务端需要@RequestBody
        ajaxPostJSON(url,params,function(result){//回调函数
            alert(result);
        })
    }
    //ajax post request
    function doAjaxPost(){
        const url="/doAjaxPost";
        const params="id=102&city=shenzhen";
        ajaxPost(url,params,function(result){//回调函数
            alert(result);
        })
    }
    //ajax get request
    function doAjaxGet(){
        const url="/doAjaxGet";
        const params="";
        ajaxGet(url,params,function(result){//回调函数
            document.querySelector("#result").innerHTML=result;
        })
    }

</script>
</body>
</html>